package com.yidu.CashManagement.mapper;

import com.yidu.BusinessParament.entity.Cash;
import com.yidu.BusinessParament.entity.ExchangeRate;
import com.yidu.CashManagement.entity.FundsAllot;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @author 苏彬
 * @date 2022/12/10 17:01
 **/
@Mapper
public interface FundsAllotMapper {
    @Select("SELECT f.*,c.`accountName` FROM fundsAllot f LEFT JOIN cash c ON f.`cashId`=c.`cashId` where 1=1 ${term} ORDER BY f.`allotTime` limit #{page},#{row}")
    List<FundsAllot> selectFundsAllot(Map map);

    @Select("select count(*) from FundsAllot where 1=1 ${term}")
    int selectFundsAllotCount(Map map);

    @Delete("delete from FundsAllot where fundsAllotId=#{fundsAllotId}")
    void deleteFundsAllot(String fundsAllotId);

    @Delete("delete from FundsAllot where businessId=#{businessId}")
    int deleteFundsAllotBusinessId(String businessId);

    @Select("select * from Cash")
    List<Cash> selectCash();

    @Select("select count(*) from Cash")
    int selectCashCount();

    @Insert("INSERT INTO fundsAllot VALUES(#{fundsAllotId},#{cashId},#{allotType},#{allotDirection},#{allotMoney},#{businessId},#{fundId},#{businessTime},#{allotTime},#{Remark})")
    int addFundsAllot(FundsAllot fundsAllot);

    @Update("update fundsAllot set  cashId=#{cashId},allotType=#{allotType},allotDirection=#{allotDirection},allotMoney=#{allotMoney},businessId=#{businessId},fundId=#{fundId},businessTime=#{businessTime},allotTime=#{allotTime},Remark=#{Remark} where fundsAllotId=#{fundsAllotId}")
    int updateFundsAllot(FundsAllot fundsAllot);
}
